<template>
  <div id="app">
    {{count}}
    <br>
    <p>当前是 <span style="color: green">{{flag}}</span> 数</p>
    <br>
    <button @click="add">+</button>
    <button @click="des">-</button>
  </div>
</template>

<script>
  export default {
    name: 'App',
    //仓库中的数据在组件上最好使用一个计算属性与之对应
    computed:{
      count(){
        return this.$store.state.count
      },
      fullName(){
        return this.$store.getters.fullName
      },
      flag(){
        return this.$store.getters.flag
      }
    },
    methods:{
      add(){
        this.$store.dispatch("add")
      },
      des(){
        this.$store.dispatch("des")
      }
    }
  }
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
